package utils

import "github.com/panjf2000/ants/v2"

type goroutineUtils struct {
}

func (goroutineUtils) Do(task func(), size int, withPreAlloc bool) error {
	p, err := ants.NewPool(size, ants.WithPreAlloc(withPreAlloc))
	if err != nil {
		return err
	}
	defer p.Release()
	return p.Submit(task)
}
